//
//  ViewController.m
//  TYJiangSu
//
//  Created by liboxiang on 2019/3/27.
//  Copyright © 2019 liboxiang. All rights reserved.
//

#import "ViewController.h"
#import "LbxCamera.h"

@interface ViewController ()
@property (strong, nonatomic) LbxCamera *camera;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 60)];
    [button setTitle:@"拍照" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(openCamera) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)openCamera {
    [LbxCamera openCamera:^(id  _Nonnull result) {
        if ([result isKindOfClass:[UIImage class]]) {
            UIImage *image = (UIImage *)result;
            NSLog(@"%@",image);
            
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, image.size.width / 5, image.size.height / 5)];
            imageView.image = image;
            [self.view addSubview:imageView];
        }
    }];
}

@end
